package com.sopaths.crawler.util;

import org.jsoup.select.Elements;

public class ElementsHelper {

	public static String textUniqueElement(Elements elements) {
		if (elements == null || elements.size() == 0) {
			return null;
		}
		return elements.get(0).text();
	}

	public static String ownTextUniqueElement(Elements elements) {
		if (elements == null || elements.size() == 0) {
			return null;
		}
		return elements.get(0).ownText();
	}

	public static String attrUniqueElement(Elements elements, String attrName) {
		if (elements == null || elements.size() == 0) {
			return null;
		}
		return elements.get(0).attr(attrName);
	}

	public static String htmlUniqueElement(Elements elements) {
		if (elements == null || elements.size() == 0) {
			return null;
		}
		return elements.get(0).html();
	}
}
